package com.clothing.customization.controller.admin;

import com.clothing.customization.dto.AccessoryInventoryDTO;
import com.clothing.customization.dto.AccessoryInventoryQueryDTO;
import com.clothing.customization.service.AccessoryInventoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

@RestController
@RequestMapping("/admin/inventory/accessory")
@RequiredArgsConstructor
@PreAuthorize("hasRole('ADMIN')")
public class AccessoryInventoryController {

    private final AccessoryInventoryService accessoryInventoryService;

    @GetMapping
    public Page<AccessoryInventoryDTO> getAccessoryList(AccessoryInventoryQueryDTO queryDTO) {
        return accessoryInventoryService.getAccessoryList(queryDTO);
    }

    @GetMapping("/{id}")
    public AccessoryInventoryDTO getAccessoryDetail(@PathVariable Long id) {
        return accessoryInventoryService.getAccessoryDetail(id);
    }

    @PostMapping
    public AccessoryInventoryDTO createAccessory(@Valid @RequestBody AccessoryInventoryDTO accessoryDTO) {
        return accessoryInventoryService.createAccessory(accessoryDTO);
    }

    @PutMapping("/{id}")
    public AccessoryInventoryDTO updateAccessory(@PathVariable Long id, 
                                               @Valid @RequestBody AccessoryInventoryDTO accessoryDTO) {
        return accessoryInventoryService.updateAccessory(id, accessoryDTO);
    }

    @DeleteMapping("/{id}")
    public void deleteAccessory(@PathVariable Long id) {
        accessoryInventoryService.deleteAccessory(id);
    }
} 